Imports EHaskins.Frc.Dashboard
Imports System.IO
Imports System.ComponentModel

Public Class Pwm
    Implements INotifyPropertyChanged

    Dim _raw As Byte
    Dim _id As Integer
    Public Sub New(ByVal id As Integer, ByVal data As Byte)
        _raw = data
        _id = id
    End Sub

    Public Property PwmID() As Integer
        Get
            Return _id
        End Get
        Set(ByVal value As Integer)
            _id = value
        End Set
    End Property
    Public Property RawValue() As Byte
        Get
            Return _raw
        End Get
        Set(ByVal value As Byte)
            If _raw = value Then
                Return
            End If
            _raw = value
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("RawValue"))
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("NormalizedValue"))
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("ServoValue"))
        End Set
    End Property

    Public Property NormalizedValue() As Single
        Get
            Return (RawValue - 128) / 128
        End Get
        Set(ByVal value As Single)
            RawValue = value * 128 + 128
        End Set
    End Property

    Public Property ServoValue() As Single
        Get
            Return RawValue / 255
        End Get
        Set(ByVal value As Single)
            RawValue = value * 255
        End Set
    End Property

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
End Class
